<?php
/* -------------------------------------
*  
*  REBUKO.RU - site about insurance
*  
*  @copyright: Marsel Hasanshin 2011
*  
*  @author: Anton Minacov
*  @email: maggotjb@gmail.com
*  
*  this file should be load first
*  
* --------------------------------------
*/

$status = "debug";
switch ($status)
{
	case "release":
		define("DOMAIN","rebuko.ru");
		$dbhost = "localhost";
		$dbuser = "gobankiru_rebuko";
		$dbpass = "fdg)45J";
		$dbname = "gobankiru_rebuko";
		ini_set("display_errors",0);
		error_reporting(0);
		break;
	case "debug":
		define("DOMAIN","myrebuko.ru");
		$dbhost = "localhost";
		$dbuser = "root";
		$dbpass = "1";
		$dbname = "insurance";
		ini_set("display_errors",1);
		error_reporting(E_ALL);
		date_default_timezone_set('Asia/Yekaterinburg');
		break;
}

define("_INDEX",1);
define("DS",DIRECTORY_SEPARATOR);
define("MAIN_DIR",dirname(__FILE__));
define("SYSTEM",MAIN_DIR.DS."_system");
ini_set("session.cookie_domain",".".DOMAIN);
session_start();

require_once SYSTEM.DS."defines.php";
require_once SYSTEM.DS."classes.php";
require_once SYSTEM.DS."functions.php";

$route = new Router();
$db = new MySQL($dbhost,$dbuser,$dbpass,$dbname);
$user = new User();

$this_city = 0;
$city = "";
$subdomain = explode(".",$_SERVER['SERVER_NAME']);
if (count($subdomain) > 1)
	$city = $subdomain[0];

if ($city != "") {
	$this_city_inf = $db->getRow("select * from `city` where `path` = '$city' limit 1");
	$this_city = $this_city_inf['city_id'];
}

$banners = $db->getTable("select `text`,`power` from `banners` order by `id`");

switch ($route->getPlace()) {

	case "main": require_once MAIN.DS.MAINPAGE; break;
	case "search": require_once MAIN.DS."search.php"; break;
	
	case "about": require_once ABOUT.DS.MAINPAGE; break;
	case "catalog": require_once CATALOG.DS.MAINPAGE; break;
	case "brokcat": require_once BROKER.DS.MAINPAGE; break;
	case "company": require_once COMPANY.DS.MAINPAGE; break;
	case "news": require_once NEWS.DS.MAINPAGE; break;
	case "service": require_once SERVICES.DS.MAINPAGE; break;
	case "vote": require_once VOTE.DS.MAINPAGE; break;
	case "partners": require_once PARTNERS.DS.MAINPAGE; break;
	case "soveti": require_once SOVETI.DS.MAINPAGE; break;
	/*case "osago_calc": require_once SITE.DS."calcs".DS."osago.php"; break;
	case "kasko_calc": require_once SITE.DS."calcs".DS."kasko.php"; break;*/
	
	case "ajax": require_once AJAX.DS.MAINPAGE; break;
	case "admin": require_once ADMIN.DS.MAINPAGE; break;
	case "agent": require_once AGENT.DS.MAINPAGE; break;

	default: require_once SITE.DS."404.php";
}

$db->close();

?>